const fs = require('fs')
const path = require('path')

var root = path.join('./dist')
let content = ''
content += readDirSync(path.join('./dist/js'))
content += readDirSync(path.join('./dist/css'))
content += readDirSync(path.join('./dist/img'))
console.log(content)
fs.writeFileSync('urls.txt', content)

function readDirSync(path) {
  let str = ''
  let pa = fs.readdirSync(path)
  pa.forEach((ele, index) => {
    let info = fs.statSync(path + '/' + ele)
    if (info.isDirectory()) {
      readDirSync(path + '/' + ele)
    } else {
      let item = path + '/' + ele
      item = item.replace('dist\\', 'http://m.brandzw.com/')
      if (item.indexOf('.html') === -1) {
        str += item + '\n'
      }
    }
  })
  return str
}
